import { Component, OnInit, Input } from '@angular/core';
import { TodoList, DataFlowPracticeService } from '../../data-flow-practice.service';


export const statusMapping = {
  todo: '未做',
  doing: '正在做',
  done: '完成'
}

@Component({
  selector: 'app-to-do-item',
  templateUrl: './to-do-item.component.html',
  styleUrls: ['./to-do-item.component.less']
})

export class ToDoItemComponent implements OnInit {
  @Input() item: TodoList;
  constructor(private service: DataFlowPracticeService) { }

  get itemStatus() {
    return statusMapping[this.item.status] || '无状态';
  }


  get statusStyle() {
    if (this.item.status === 'done') {
      return {
        textDecorationLine: 'line-through',
        background: '#e6e3e3',
        color: '#a2a2a2'
      }
    }
    if (this.item.status === 'doing') {
      return {
        color: '#ff8100'
      }
    }
    return null;
  }

  ngOnInit(): void {
  }
  deleteItem() { }
}
